package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 清分账单数据 异常类型
 */
@Getter
@AllArgsConstructor
public enum SettlementBillDataExceptionTypeEnum implements BaseEnum<String> {
    NOTHING("0", "无异常"),
    RULE_MISSING("1", "规则缺失"),
    AMOUNT_ABNORMAL("2", "金额异常");
    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<SettlementBillDataExceptionTypeEnum> found = Arrays.stream(SettlementBillDataExceptionTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
